----------------
-- PROTOTYPES --
----------------
local Locales = {
	["Phagetech Commander"] = {
		[1] = "Phagetech Commander",
		[2] = "Phagentech-Kommandant",
		[3] = "Commandant technophage",
	},
	["Phagetech Augmentor"] = {
		[1] = "Phagetech Augmentor",
		[2] = "Phagentech-Augmentor",
		[3] = "Augmenteur technophage",
	},
	["Phagetech Protector"] = {
		[1] = "Phagetech Protector",
		[2] = "Phagentech-Protektor",
		[3] = "Protecteur technophage",
	},
	["Phagetech Fabricator"] = {
		[1] = "Phagetech Fabricator",
		[2] = "Phagentech-Fabrikant",
		[3] = "Fabricant technophage",
	},
	["Powering Up"] = { --59802
		[1] = "Powering Up",
		[2] = "Hochfahren",
		[3] = "Mise en marche",
	},
	["Powering Down"] = { --59801
		[1] = "Powering Down",
		[2] = "Herunterfahren",
		[3] = "Coupure de courant",
	},
	["Forced Production"] = { --60810
		[1] = "Forced Production",
		[2] = "Erzwungene Produktion",
		[3] = "Production forcée",
	},
	["Destruction Protocol"] = { --59662
		[1] = "Destruction Protocol",
		[2] = "Zerstörungsprotokoll",
		[3] = "Protocole de destruction",
	},
	["Malicious Uplink"] = { --66646
		[1] = "Malicious Uplink",
		[2] = "Bösartiger Uplink",
		[3] = "Liaison railleuse",
	},
	["Phagetech Borer"] = { --64840
		[1] = "Phagetech Borer",
		[2] = "Phagentech-Bohrer",
		[3] = "Foreuse technophage",
	},
	["Summon Repairbot"] = { --59758
		[1] = "Summon Repairbot",
		[2] = "Reparaturbot herbeirufen",
		[3] = "Déployer Bricobot",
	},
	["Pulse-A-Tron Wave"] = { --59707
		[1] = "Pulse-A-Tron Wave",
		[2] = "Pulsatron-Welle",
		[3] = "Vague pulsatomique",
	},
	["Gravitational Singularity"] = { --66475
		[1] = "Gravitational Singularity",
		[2] = "Gravitationssingularität",
		[3] = "Singularité gravitationnelle",
	},
	["Summon Destructobot"] = { --59757
		[1] = "Summon Destructobot",
		[2] = "Destruktobot herbeirufen",
		[3] = "Déployer Destructobot",
	},
	["Technophage Catalyst"] = { --66487
		[1] = "Technophage Catalyst",
		[2] = "Technophagen-Katalysator",
		[3] = "Catalyse technophage",
	},
	["SOAK THE METEORS!!!"] = {
		[1] = "SOAK THE METEORS!!!",
		[2] = "METEORITEN ABFANGEN!!!",
		[3] = "ETINCELLES!!!",
	},
	["BREAK THE CHAINS!!!"] = {
		[1] = "BREAK THE CHAINS!!!",
		[2] = "ZERSTÖR DIE KETTEN!!!",
		[3] = "CASSEZ LES CHAINES!!!",
	},
}

local function GAPrototypes(tUnits)
	local locChains = Raiderino.L["BREAK THE CHAINS!!!"]
	
	local currTime = GameLib.GetGameTime()
	for unitid, unitdata in pairs(tUnits) do
		local unitname = unitdata.unit:GetName()
		if unitname == Raiderino.L["Phagetech Commander"] then
			local castname = Raiderino:GetCast(unitid,unitdata.unit)
			if castname then
				if castname == Raiderino.L["Forced Production"] then
					if Raiderino:FeatureCheck("Phagetech Commander","Forced Production") then
						local msg = {text = "Forced Production", maxtime = 36, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["Destruction Protocol"] then
					if Raiderino:FeatureCheck("Phagetech Commander","Destruction Protocol") then
						local msg = {text = "Destruction Protocol", maxtime = 17, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["v Up"] then
					if Raiderino:FeatureCheck("Phagetech Commander","Malicious Uplink") then
						local msg = {text = "Malicious Uplink", maxtime = 5, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["Powering Down"] then
					if Raiderino.timers.content["Forced Production"] then
						Raiderino.timers.content["Forced Production"].Frame:Destroy()
						Raiderino.timers.content["Forced Production"] = nil
					end
					if Raiderino.timers.content["Destruction Protocol"] then
						Raiderino.timers.content["Destruction Protocol"].Frame:Destroy()
						Raiderino.timers.content["Destruction Protocol"] = nil
					end
				else
					Raiderino:UntimedCastAdd(unitname,castname)
				end
			end
		elseif unitname == Raiderino.L["Phagetech Augmentor"] then
			local castname = Raiderino:GetCast(unitid,unitdata.unit)
			if castname then
				if castname == Raiderino.L["Phagetech Borer"] then
					if Raiderino:FeatureCheck("Phagetech Augmentor","Phagetech Borer") then
						local msg = {text = "Phagetech Borer", maxtime = 17, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["Summon Repairbot"] then
					if Raiderino:FeatureCheck("Phagetech Augmentor","Summon Repairbot") then
						local msg = {text = "Summon Repairbot", maxtime = 17, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["Powering Down"] then
					if Raiderino.timers.content["Phagetech Borer"] then
						Raiderino.timers.content["Phagetech Borer"].Frame:Destroy()
						Raiderino.timers.content["Phagetech Borer"] = nil
					end
					if Raiderino.timers.content["Summon Repairbot"] then
						Raiderino.timers.content["Summon Repairbot"].Frame:Destroy()
						Raiderino.timers.content["Summon Repairbot"] = nil
					end
				else
					Raiderino:UntimedCastAdd(unitname,castname)
				end
			end
		elseif unitname == Raiderino.L["Phagetech Protector"] then
			local castname = Raiderino:GetCast(unitid,unitdata.unit)
			if castname then
				if castname == Raiderino.L["Pulse-A-Tron Wave"] then
					if Raiderino:FeatureCheck("Phagetech Protector","Pulse-A-Tron Wave") then
						local msg = {text = "Pulse-A-Tron Wave", maxtime = 15, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["Powering Up"] then
					if Raiderino:FeatureCheck("Phagetech Protector","Gravitational Singularity") then
						local msg = {text = "Gravitational Singularity", maxtime = 7, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["Powering Down"] then
					if Raiderino.timers.content["Pulse-A-Tron Wave"] then
						Raiderino.timers.content["Pulse-A-Tron Wave"].Frame:Destroy()
						Raiderino.timers.content["Pulse-A-Tron Wave"] = nil
					end
				else
					Raiderino:UntimedCastAdd(unitname,castname)
				end
			end
		elseif unitname == Raiderino.L["Phagetech Fabricator"] then
			local castname = Raiderino:GetCast(unitid,unitdata.unit)
			if castname then
				if castname == Raiderino.L["Summon Destructobot"] then
					if Raiderino:FeatureCheck("Phagetech Fabricator","Summon Destructobot") then
						local msg = {text = "Summon Destructobot", maxtime = 16, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["Powering Up"] then
					if Raiderino:FeatureCheck("Phagetech Fabricator","Technophage Catalyst") then
						local msg = {text = "Technophage Catalyst", maxtime = 10, icon = nil, destroyAtEnd = true}
						Raiderino.timers:AddTimer(msg)
					end
				elseif castname == Raiderino.L["Powering Down"] then
					if Raiderino.timers.content["Summon Destructobot"] then
						Raiderino.timers.content["Summon Destructobot"].Frame:Destroy()
						Raiderino.timers.content["Summon Destructobot"] = nil
					end
				else
					Raiderino:UntimedCastAdd(unitname,castname)
				end
			end
		end
	end
	
	if Raiderino:FeatureCheck("Phagetech Fabricator","SOAK THE METEORS!!!") then
		if Raiderino.timers.content["Technophage Catalyst"] and not Raiderino.timers.content["Technophage Catalyst"].notified then
			if Raiderino.timers.content["Technophage Catalyst"].EndTime - currTime < 1 and not Raiderino.notifications.content["SOAK THE METEORS!!!"] then
				local msg = {text = "SOAK THE METEORS!!!", maxtime = 8, icon = nil, destroyAtEnd = true}
				Raiderino.notifications:AddTimer(msg)
				Raiderino.notifications.content["Technophage Catalyst"].notified = true
			end
		end
	end
	
	if Raiderino:FeatureCheck("Phagetech Commander","Malicious Uplink") then
		local player = GameLib.GetPlayerUnit()
		local debuffs = player:GetBuffs().arHarmful
		for _, debuff in pairs(debuffs) do
			if debuff.splEffect:GetName() == Raiderino.L["Malicious Uplink"] then
				if not Raiderino.notifications.content["BREAK THE CHAINS!!!"] then
					local msg = {text = "BREAK THE CHAINS!!!", maxtime = 5, icon = nil, destroyAtEnd = true}
					Raiderino.notifications:AddTimer(msg)
				end
			end
		end
	end
end

local function PhaseCommander(phase)

end

local function StartCommander()

end

local function PhaseAugmentor(phase)

end

local function StartAugmentor()

end

local function PhaseProtector(phase)

end

local function StartProtector()

end

local function PhaseFabricator(phase)

end

local function StartFabricator()

end
-----------------
-- /PROTOTYPES --
-----------------

if _G["RaiderinoLibs"] == nil then
	_G["RaiderinoLibs"] = { }
end
if _G["RaiderinoLibs"]["Encounters"] == nil then
	_G["RaiderinoLibs"]["Encounters"] = { }
end

local encounteroptions = {
	enabled = true,
	position = 3,
	zone = "Genetic Archives - Act 2",
	fBossFunction = GAPrototypes,
	fPhaseFunction = PhaseCommander,
	fOnStartCombat = StartCommander,
	features = {
		["Forced Production"] = {
			displayname = "Forced Production",
			enabled = true
		},
		["Destruction Protocol"] = {
			displayname = "Destruction Protocol",
			enabled = true
		},
		["Malicious Uplink"] = {
			displayname = "Malicious Uplink",
			enabled = true
		},
	},
}

_G["RaiderinoLibs"]["Encounters"]["Phagetech Commander"] = encounteroptions

local encounteroptions = {
	enabled = true,
	position = 4,
	zone = "Genetic Archives",
	fBossFunction = GAPrototypes,
	fPhaseFunction = PhaseAugmentor,
	fOnStartCombat = StartAugmentor,
	features = {
		["Phagetech Borer"] = {
			displayname = "Phagetech Borer",
			enabled = true
		},
		["Summon Repairbot"] = {
			displayname = "Summon Repairbot",
			enabled = true
		},
	},
}

_G["RaiderinoLibs"]["Encounters"]["Phagetech Augmentor"] = encounteroptions

local encounteroptions = {
	enabled = true,
	position = 5,
	zone = "Genetic Archives",
	fBossFunction = GAPrototypes,
	fPhaseFunction = PhaseProtector,
	fOnStartCombat = StartProtector,
	features = {
		["Pulse-A-Tron Wave"] = {
			displayname = "Pulse-A-Tron Wave",
			enabled = true
		},
		["Gravitational Singularity"] = {
			displayname = "Gravitational Singularity",
			enabled = true
		},
		
	},
}

_G["RaiderinoLibs"]["Encounters"]["Phagetech Protector"] = encounteroptions

local encounteroptions = {
	enabled = true,
	position = 6,
	zone = "Genetic Archives",
	fBossFunction = GAPrototypes,
	fPhaseFunction = PhaseFabricator,
	fOnStartCombat = StartFabricator,
	features = {
		["Summon Destructobot"] = {
			displayname = "Summon Destructobot",
			enabled = true
		},
		["Technophage Catalyst"] = {
			displayname = "Technophage Catalyst",
			enabled = true
		},
		["SOAK THE METEORS!!!"] = {
			displayname = "SOAK THE METEORS!!!",
			enabled = true
		},
	},
}

_G["RaiderinoLibs"]["Encounters"]["Phagetech Fabricator"] = encounteroptions

if _G["RaiderinoLibs"]["Locales"] == nil then
	_G["RaiderinoLibs"]["Locales"] = { }
end
for locale, localedata in pairs(Locales) do
	if not RaiderinoLibs.Locales[locale] then
		RaiderinoLibs.Locales[locale] = {}
		for i,localestring in pairs(localedata) do
			RaiderinoLibs.Locales[locale][i] = localestring
		end
	end
end